/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Graphic;

import businessLogic.PlayerActions;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import javax.swing.ImageIcon;
import scala40rules.CardSet;

/**
 *
 * @author macbook
 */
public class ChoiseValueJoker extends javax.swing.JFrame implements Serializable{
    /**
	 *
	 */
	private static final long serialVersionUID = 1L;

     // Variables declaration - do not modify
    private javax.swing.JButton button1;
    private javax.swing.JButton button2;
    private javax.swing.JButton button3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private int suitedJoker=-3;
    private PlayerActions playerActions;
    // End of variables declaration

    /** Creates new form ChoiseValue */
    public ChoiseValueJoker(PlayerActions p) {
        playerActions=p;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        button1 = new javax.swing.JButton();
        button2 = new javax.swing.JButton();
        button3 = new javax.swing.JButton();
        
        
        


        button1.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println("Scelta opzione 1");
                    playerActions.setJokerChosen(0);
                    dispose();
            }}
        );

        button2.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println("Scelta opzione 2");
                    playerActions.setJokerChosen(1);
                    dispose();
            }}
        );

        button3.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println("Scelta opzione 3");
                    playerActions.setJokerChosen(2);
                    dispose();
            }}
        );


        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("SansSerif", 0, 14));
        jLabel1.setForeground(new java.awt.Color(0, 0, 204));
        jLabel1.setText("Valore del Joker?");

        jPanel1.setBackground(new java.awt.Color(153, 153, 153));
        jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 204), 2, true));

       

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(button1))
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(button2))
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(button3)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(button1)
                .add(18, 18, 18)
                .add(button2)
                .add(18, 18, 18)
                .add(button3)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(12, 12, 12)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 44, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }

    

    /**
    * @param args the command line arguments
    */

    public void message(CardSet cardset){

        setBounds(100, 140, 140, 500);
        setVisible(true);


    	setVisible(true);

        switch(cardset.size()){
            case 1:
                    setBounds(100, 140, 140, 500);
                    ImageIcon icon = new ImageIcon(cardset.getCard(0).getImage());
                    button1.setVisible(true);button2.setVisible(false);button3.setVisible(false);
                    button1.setIcon(icon);
                    break;

            case 2:
                    setBounds(100, 140, 140, 370);
                    ImageIcon icon1 = new ImageIcon(cardset.getCard(0).getImage());
                    ImageIcon icon2 = new ImageIcon(cardset.getCard(1).getImage());
                    button1.setVisible(true);button2.setVisible(true);button3.setVisible(false);
                    button1.setIcon(icon1);button2.setIcon(icon2);
                    break;

            case 3:
                    setBounds(100, 140, 140, 500);
                    ImageIcon icon01 = new ImageIcon(cardset.getCard(0).getImage());
                    ImageIcon icon02 = new ImageIcon(cardset.getCard(1).getImage());
                    ImageIcon icon03 = new ImageIcon(cardset.getCard(2).getImage());
                    button1.setVisible(true);button2.setVisible(true);button3.setVisible(true);
                    button1.setIcon(icon01);button2.setIcon(icon02);button3.setIcon(icon03);
                    break;

        }

    }

}